libxl: fd events: Suppress spurious fd events
Always recheck with poll() right before making the callback.
All sorts of things may have happened since poll() originally signaled
the fd. We would like the main functional libxl code not to have to
worry about spurious wakeups.
In particular, this fixes a bug in the save/restore callout: the save
helper message reader operates with the fd in blocking mode. In a
multithreaded program one thread might have eaten all the messages out
of the fd while another one is busy returning from poll and reacquiring
the libxl lock, possibly resulting in a deadlock.
(Also, we abolish the anomalous direct caller of efd->func.)
Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reported-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Jim Fehlig <jfehlig@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>